package com.baizhi.action;

import com.baizhi.entity.Tag;
import com.baizhi.service.impl.TagServiceImpl;
import com.baizhi.service.tagService;
import com.opensymphony.xwork2.ActionSupport;

import java.sql.Date;
import java.util.List;

public class TagAction extends ActionSupport {
    //标签对象
    Tag tag;
    int id;
    List<Tag> tags;



    //添加标签
   public String insertTag(){

       tagService ts =new TagServiceImpl();
       tag.setCreateDate(new java.util.Date());

       ts.insertTag(tag);

       return "insertsuccess";
   }




    //删除标签
    public String deleteTag(){

        tagService ts =new TagServiceImpl();
         ts.deleteById(id);

       return "delectsuccess";
    }


    //查询所有标签
    public String queryAllTags(){

        tagService ts =new TagServiceImpl();
        tags = ts.queryAll();

//        for (Tag tag1 : tags) {
//            tag1.setCreateDate(new Date(tag1.getCreateDate().getTime()));
//        }
//        System.out.println(tags);

        return "queryAllsuccess";
    }



    //get/set
    public List<Tag> getTags() {
        return tags;
    }

    public void setTags(List<Tag> tags) {
        this.tags = tags;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Tag getTag() {
        return tag;
    }

    public void setTag(Tag tag) {
        this.tag = tag;
    }
}
